home *** CD-ROM | disk | FTP | other *** search
- /*
- * ⌐ Graeme Gerrard 1990
- * Faculty of Music, University of Melbourne
- * Parkville Victoria 3052 Australia.
- *
- * ARPANET: grae@murdu.ucs.unimelb.edu.au
- * telephone: (613) 344 4127, Fax: (613) 344 5346
- */
- #include "Music4C.h"
- #include "Synthesis_Time.h"
- #include "Synthesis_Progress.h"
- #include "Preferences_Dialog.h"
- #include "Pass1_2.h"
- #include "About_Dialog_Box.h"
- #include "Music4C_Prototype.h"
-
- void main(void);
- void CheckSystem(void);
- void myInit(void);
- void GetMusic4C_Prefs(void);
-
-
- extern void InitMyMenus(void);
- extern void HandleMenu(char *doneFlag, short theMenu, short theItem, TEHandle *theInput);
-
-
-
-
-
- float MaxSample;
- float MinSample;
- double TotalDuration;
- Boolean CreateSoundFile;
- DialogPtr myDialog;
- int SFoutputType;
- Str255 ScoreDirectoryName;
- int ReportFileRefNum;
- long StartUpDirID;
- long SoundFileDirID;
- int SFSaveVRef;
- int SFvRefNum;
- Str255 StartDirName, SFDirectoryName;
- Str255 FileFormat;
- SysEnvRec SysEnvData;
-
-
- int RunUpTo;
- int ReportFlags;
- int out1_flag; /* pass1 output flag */
- int out2_flag; /* pass2 output flag */
- int out3_flag; /* pass3 output flag */
- int RunToPass1; /* test pass1 only */
- int RunToPass2; /* test up to pass2 only */
- int RunToPass3; /* test pass3 only, i.e. don't write sample file */
- int rescale_flag; /* write integer file */
- int dump_samps_flag; /* dump sample values to stdout */
- double srate; /* sampling rate */
- int nchnls; /* number of output channels */
- Str255 sfile;
- Str255 rfile;
- Handle myMenuHandle;
- double rescalingConst; /* sample rescaling constant */
- int AppResFile;
- Boolean AIFFoddByte;
- long TotalSamps;
- int scoreRefNum;
- OSErr theErr;
-
-
-
- void main()
- {
- char doneFlag;
- char Is_A_Dialog;
- char stillInGoAway;
- char ch;
- short code;
- short theMenu,theItem;
- short chCode;
- long mResult;
- WindowPtr whichWindow;
- EventRecord myEvent;
- TEHandle theInput;
- Rect tempRect,OldRect;
- Point myPt;
- GrafPtr SavePort;
- long myLong;
- Ptr myPtr;
-
-
- /* SetApplLimit(GetApplLimit());*/
- SetApplLimit((Ptr)ApplicZone+maxSize);
- /* MaxApplZone();*/
- MoreMasters();
-
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
- CheckSystem();
- myInit();
-
- /* OpenResFile("\pMusic4C_Prototype.RSRC");*/
-
- doneFlag = FALSE;
-
- InitMyMenus();
-
- theInput = NIL;
-
- do
- {
- if (theInput != NIL)
- TEIdle(theInput);
- SystemTask();
-
-
- if (GetNextEvent(everyEvent, &myEvent))
- {
- code = FindWindow(myEvent.where, &whichWindow);
-
-
- switch (myEvent.what)
- {
- case mouseDown:
- if (code == inMenuBar)
- {
- mResult = MenuSelect(myEvent.where);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- HandleMenu(&doneFlag,theMenu,theItem,&theInput);
- }
-
- if ((code == inDrag)&&(whichWindow != NIL))
- {
- tempRect = screenBits.bounds;
- SetRect(&tempRect, tempRect.left + 10, tempRect.top + 25, tempRect.right - 10, tempRect.bottom - 10);
- DragWindow(whichWindow, myEvent.where, &tempRect);
- }
-
- if (code == inGrow)
- {
- SetPort(whichWindow);
-
- myPt = myEvent.where;
- GlobalToLocal(&myPt);
-
- OldRect.left = whichWindow->portRect.left;
- OldRect.right = whichWindow->portRect.right;
- OldRect.top = whichWindow->portRect.top;
- OldRect.bottom = whichWindow->portRect.bottom;
-
- SetRect(&tempRect,15,15,(screenBits.bounds.right - screenBits.bounds.left), (screenBits.bounds.bottom - screenBits.bounds.top) - 20);
- mResult = GrowWindow(whichWindow, myEvent.where, &tempRect);
- SizeWindow(whichWindow, LoWord(mResult), HiWord(mResult), TRUE);
-
-
- SetPort(whichWindow);
-
- SetRect(&tempRect, 0, myPt.v - 15, myPt.h + 15, myPt.v + 15);
- EraseRect(&tempRect);
- InvalRect(&tempRect);
- SetRect(&tempRect, myPt.h - 15, 0, myPt.h + 15, myPt.v + 15);
- EraseRect(&tempRect);
- InvalRect(&tempRect);
- DrawGrowIcon(whichWindow);
- }
-
- if (code == inGoAway)
- {
- stillInGoAway = TrackGoAway(whichWindow,myEvent.where);
- if (stillInGoAway == TRUE)
- {
- }
- }
-
- if (code == inContent)
- {
- if (whichWindow != FrontWindow())
- {
- SelectWindow(whichWindow);
- }
- else
- {
- SetPort(whichWindow);
- }
- }
-
- if (code == inSysWindow)
- {
- SystemClick(&myEvent, whichWindow);
- }
-
- if ((code == inZoomIn) || (code == inZoomOut))
- {
- if (whichWindow != NIL)
- {
- SetPort(whichWindow);
-
- myPt = myEvent.where;
- GlobalToLocal(&myPt);
-
- if (TrackBox(whichWindow, myPt, code) == TRUE)
- {
- ZoomWindow(whichWindow, code, TRUE);
- SetRect(&tempRect, 0, 0, 32000, 32000);
- EraseRect(&tempRect);
- InvalRect(&tempRect);
-
- }
- }
- }
-
- break;
-
- case keyDown:
- case autoKey:
- ch = myEvent.message & charCodeMask;
- if (myEvent.modifiers & cmdKey)
- {
- mResult = MenuKey(ch);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- if (theMenu != 0)
- HandleMenu(&doneFlag, theMenu, theItem, &theInput);
- if (((ch == 'x') || (ch == 'X')) && (theInput != NIL))
- TECut(theInput);
- if (((ch == 'c') || (ch == 'C')) && (theInput != NIL))
- TECopy(theInput);
- if (((ch == 'v') || (ch == 'V')) && (theInput != NIL))
- TEPaste(theInput);
- }
- else if (theInput != NIL)
- TEKey(ch,theInput);
- break;
-
- case updateEvt:
- whichWindow = (WindowPtr)myEvent.message;
- GetPort(&SavePort);
- BeginUpdate(whichWindow);
- SetPort(whichWindow);
- EndUpdate(whichWindow);
- SetPort(SavePort);
- break;
-
- case diskEvt:
- if (HiWord(myEvent.message) != 0)
- {
- myEvent.where.h = ((screenBits.bounds.right - screenBits.bounds.left) / 2) - (304 / 2);
- myEvent.where.v = ((screenBits.bounds.bottom - screenBits.bounds.top) / 3) - (104 / 2);
- InitCursor();
- theItem = DIBadMount(myEvent.where, myEvent.message);
- }
- break;
-
- case activateEvt:
- if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag))
- {
- SelectWindow(whichWindow);
- }
- break;
-
-
- default:
- break;
-
- }
-
- }
- }
- while (doneFlag == FALSE);
-
- }
-
- void myInit()
- {
- AppResFile = CurResFile();
- StartUpDirID = CurDirStore;
- rescale_flag = FALSE;
-
- ScoreDirectoryName[0] = 0;
- CreateSoundFile = TRUE;
- SFoutputType = FLOAT;
- PstringCopy((char *)FileFormat, "\pFLOAT");
- ReportFlags = 7;
- RunUpTo = 4;
- RunToPass1 = 0;
- RunToPass2 = 0;
- RunToPass3 = 0;
- out1_flag = 1;
- out2_flag = 1;
- out3_flag = 1;
- GetMusic4C_Prefs();
- }
-
- void CheckSystem()
- {
- OSErr theErr = SysEnvirons(1, &SysEnvData);
- if (SysEnvData.hasFPU)
- return;
- ParamText("\pSome of the code for Music4C", "\prequires a floating point unit", NIL, NIL);
- A_ErrorAlert();
- ExitToShell();
- }
-
-
- MenuHandle AppleMenu;
-
- void InitMyMenus(void);
-
-
- void InitMyMenus()
- {
-
- /* Menu resource ID for */
- #define Menu_1 1001
- /* Menu resource ID for File */
- #define Menu_2 1002
-
- MenuHandle tempMenu;
-
- ClearMenuBar();
-
- /* Apple menu */
- tempMenu = GetMenu(Menu_1);
- InsertMenu (tempMenu,0);
- AddResMenu(tempMenu,'DRVR');
- AppleMenu = tempMenu;
-
- /* This menu is File */
- tempMenu = GetMenu(Menu_2);
- InsertMenu (tempMenu,0);
-
- DrawMenuBar();
-
- }
-
-
-